def test_empty(self): update_server_info(self.repo) with open(os.path.join(self.path, ".git", "info", "refs"), 'rb') as f: self.assertEqual(b'', f.read()) with open(os.path.join(self.path, ".git", "objects", "info", "packs"), 'rb') as f: self.assertEqual(b'', f.read())
def test_simple(self): commit_id = self.repo.do_commit(message="foo", committer="Joe Example <*****@*****.**>", ref="refs/heads/foo") update_server_info(self.repo) ref_text = open(os.path.join(self.path, ".git", "info", "refs"), "r").read() self.assertEqual(ref_text, "%s\trefs/heads/foo\n" % commit_id) packs_text = open(os.path.join(self.path, ".git", "objects", "info", "packs"), "r").read() self.assertEqual(packs_text, "")
def test_empty(self): update_server_info(self.repo) with open(os.path.join(self.path, ".git", "info", "refs"), 'rb') as f: self.assertEqual(b'', f.read()) p = os.path.join(self.path, ".git", "objects", "info", "packs") with open(p, 'rb') as f: self.assertEqual(b'', f.read())
def run(event, context): dulwich.client.get_ssh_vendor = git.KeyParamikoSSHVendor repo = porcelain.clone( "remote_repository", "/tmp/repo" ) server.update_server_info(repo) with open("/tmp/repo/.git/info/refs") as r: print(r.read())
def test_simple(self): commit_id = self.repo.do_commit( message=b"foo", committer=b"Joe Example <*****@*****.**>", ref=b"refs/heads/foo" ) update_server_info(self.repo) with open(os.path.join(self.path, ".git", "info", "refs"), "rb") as f: self.assertEqual(f.read(), commit_id + b"\trefs/heads/foo\n") with open(os.path.join(self.path, ".git", "objects", "info", "packs"), "rb") as f: self.assertEqual(f.read(), b"")
def test_empty(self): update_server_info(self.repo) self.assertEqual( "", open(os.path.join(self.path, ".git", "info", "refs"), 'r').read()) self.assertEqual( "", open(os.path.join(self.path, ".git", "objects", "info", "packs"), 'r').read())
def test_simple(self): commit_id = self.repo.do_commit( message="foo", committer="Joe Example <*****@*****.**>", ref="refs/heads/foo") update_server_info(self.repo) ref_text = open(os.path.join(self.path, ".git", "info", "refs"), 'r').read() self.assertEquals(ref_text, "%s\trefs/heads/foo\n" % commit_id) packs_text = open(os.path.join(self.path, ".git", "objects", "info", "packs"), 'r').read() self.assertEquals(packs_text, "")
def test_simple(self): commit_id = self.repo.do_commit( message=b"foo", committer=b"Joe Example <*****@*****.**>", ref=b"refs/heads/foo") update_server_info(self.repo) with open(os.path.join(self.path, ".git", "info", "refs"), 'rb') as f: self.assertEqual(f.read(), commit_id + b'\trefs/heads/foo\n') with open(os.path.join(self.path, ".git", "objects", "info", "packs"), 'rb') as f: self.assertEqual(f.read(), b'')
def _update_server_info(self): """ runs gits update-server-info command in this repo instance """ from dulwich.server import update_server_info try: update_server_info(self._repo) except OSError as e: if e.errno not in [errno.ENOENT, errno.EROFS]: raise # Workaround for dulwich crashing on for example its own dulwich/tests/data/repos/simple_merge.git/info/refs.lock log.error('Ignoring %s running update-server-info: %s', type(e).__name__, e)
def backend(self, req, environ): """ WSGI Response producer for HTTP POST Git Smart HTTP requests. Reads commands and data from HTTP POST's body. returns an iterator obj with contents of git command's response to stdout """ _git_path = kallithea.CONFIG.get('git_path', 'git') git_command = self._get_fixedpath(req.path_info) if git_command not in self.commands: log.debug('command %s not allowed', git_command) return exc.HTTPMethodNotAllowed() if 'CONTENT_LENGTH' in environ: inputstream = FileWrapper(environ['wsgi.input'], req.content_length) else: inputstream = environ['wsgi.input'] gitenv = dict(os.environ) # forget all configs gitenv['GIT_CONFIG_NOGLOBAL'] = '1' cmd = [ _git_path, git_command[4:], '--stateless-rpc', self.content_path ] log.debug('handling cmd %s', cmd) try: out = subprocessio.SubprocessIOChunker( cmd, inputstream=inputstream, env=gitenv, cwd=self.content_path, ) except EnvironmentError as e: log.error(traceback.format_exc()) raise exc.HTTPExpectationFailed() if git_command in ['git-receive-pack']: # updating refs manually after each push. # Needed for pre-1.7.0.4 git clients using regular HTTP mode. from kallithea.lib.vcs import get_repo from dulwich.server import update_server_info repo = get_repo(self.content_path) if repo: update_server_info(repo._repo) resp = Response() resp.content_type = 'application/x-%s-result' % git_command.encode( 'utf-8') resp.charset = None resp.app_iter = out return resp
def backend(self, request, environ): """ WSGI Response producer for HTTP POST Git Smart HTTP requests. Reads commands and data from HTTP POST's body. returns an iterator obj with contents of git command's response to stdout """ _git_path = kallithea.CONFIG.get('git_path', 'git') git_command = self._get_fixedpath(request.path_info) if git_command not in self.commands: log.debug('command %s not allowed', git_command) return exc.HTTPMethodNotAllowed() if 'CONTENT_LENGTH' in environ: inputstream = FileWrapper(environ['wsgi.input'], request.content_length) else: inputstream = environ['wsgi.input'] gitenv = dict(os.environ) # forget all configs gitenv['GIT_CONFIG_NOGLOBAL'] = '1' cmd = [_git_path, git_command[4:], '--stateless-rpc', self.content_path] log.debug('handling cmd %s', cmd) try: out = subprocessio.SubprocessIOChunker( cmd, inputstream=inputstream, env=gitenv, cwd=self.content_path, ) except EnvironmentError as e: log.error(traceback.format_exc()) raise exc.HTTPExpectationFailed() if git_command in [u'git-receive-pack']: # updating refs manually after each push. # Needed for pre-1.7.0.4 git clients using regular HTTP mode. from kallithea.lib.vcs import get_repo from dulwich.server import update_server_info repo = get_repo(self.content_path) if repo: update_server_info(repo._repo) resp = Response() resp.content_type = 'application/x-%s-result' % git_command.encode('utf8') resp.charset = None resp.app_iter = out return resp
def update_server_info(self): if not self.is_bare: return update_server_info(self.repo)
cmd, inputstream=inputstream, **opts ) except EnvironmentError, e: log.error(traceback.format_exc()) raise exc.HTTPExpectationFailed() if git_command in [u'git-receive-pack']: # updating refs manually after each push. # Needed for pre-1.7.0.4 git clients using regular HTTP mode. from kallithea.lib.vcs import get_repo from dulwich.server import update_server_info repo = get_repo(self.content_path) if repo: update_server_info(repo._repo) resp = Response() resp.content_type = 'application/x-%s-result' % git_command.encode('utf8') resp.charset = None resp.app_iter = out return resp def __call__(self, environ, start_response): request = Request(environ) _path = self._get_fixedpath(request.path_info) if _path.startswith('info/refs'): app = self.inforefs elif [a for a in self.valid_accepts if a in request.accept]: app = self.backend try:
def test_empty(self): update_server_info(self.repo) self.assertEqual("", open(os.path.join(self.path, ".git", "info", "refs"), 'r').read()) self.assertEqual("", open(os.path.join(self.path, ".git", "objects", "info", "packs"), 'r').read())
def run(event, context): dulwich.client.get_ssh_vendor = git.KeyParamikoSSHVendor repo = porcelain.clone("remote_repository", "/tmp/repo") server.update_server_info(repo) with open("/tmp/repo/.git/info/refs") as r: print(r.read())
def update_server_info(self, wire): repo = self._factory.repo(wire) update_server_info(repo)
def _update_server_info(self): """ runs gits update-server-info command in this repo instance """ from dulwich.server import update_server_info update_server_info(self._repo)
log.debug('handling cmd %s' % cmd) out = subprocessio.SubprocessIOChunker(cmd, inputstream=inputstream, **opts) except EnvironmentError, e: log.error(traceback.format_exc()) raise exc.HTTPExpectationFailed() if git_command in [u'git-receive-pack']: # updating refs manually after each push. # Needed for pre-1.7.0.4 git clients using regular HTTP mode. from kallithea.lib.vcs import get_repo from dulwich.server import update_server_info repo = get_repo(self.content_path) if repo: update_server_info(repo._repo) resp = Response() resp.content_type = 'application/x-%s-result' % git_command.encode( 'utf8') resp.charset = None resp.app_iter = out return resp def __call__(self, environ, start_response): request = Request(environ) _path = self._get_fixedpath(request.path_info) if _path.startswith('info/refs'): app = self.inforefs elif [a for a in self.valid_accepts if a in request.accept]: app = self.backend