コード例 #1
0
        def remote_repo_creator(self):
            remote_repo_dir = maketemp("remote_repo_%s" % func.__name__)
            repo_dir = maketemp("remote_clone_non_bare_repo")

            rw_remote_repo = self.rorepo.clone(remote_repo_dir,
                                               shared=True,
                                               bare=True)
            rw_repo = rw_remote_repo.clone(
                repo_dir, shared=True, bare=False,
                n=True)  # recursive alternates info ?
            rw_repo.head.commit = working_tree_ref
            rw_repo.head.reference.checkout()

            # prepare for git-daemon
            rw_remote_repo.daemon_export = True

            # this thing is just annoying !
            crw = rw_remote_repo.config_writer()
            section = "daemon"
            try:
                crw.add_section(section)
            except Exception:
                pass
            crw.set(section, "receivepack", True)
            # release lock
            del (crw)

            # initialize the remote - first do it as local remote and pull, then
            # we change the url to point to the daemon. The daemon should be started
            # by the user, not by us
            d_remote = Remote.create(rw_repo, "daemon_origin", remote_repo_dir)
            d_remote.fetch()
            remote_repo_url = "git://localhost%s" % remote_repo_dir

            d_remote.config_writer.set('url', remote_repo_url)

            # try to list remotes to diagnoes whether the server is up
            try:
                rw_repo.git.ls_remote(d_remote)
            except GitCommandError, e:
                print str(e)
                if os.name == 'nt':
                    raise AssertionError(
                        'git-daemon needs to run this test, but windows does not have one. Otherwise, run: git-daemon "%s"'
                        % os.path.dirname(_mktemp()))
                else:
                    raise AssertionError(
                        'Please start a git-daemon to run this test, execute: git-daemon "%s"'
                        % os.path.dirname(_mktemp()))
コード例 #2
0
        def repo_creator(self):
            prefix = 'non_'
            if bare:
                prefix = ''
            # END handle prefix
            repo_dir = maketemp("%sbare_%s" % (prefix, func.__name__))
            rw_repo = self.rorepo.clone(repo_dir, shared=True, bare=bare, n=True)

            rw_repo.head.commit = rw_repo.commit(working_tree_ref)
            if not bare:
                rw_repo.head.reference.checkout()
            # END handle checkout

            prev_cwd = os.getcwd()
            os.chdir(rw_repo.working_dir)
            try:
                try:
                    return func(self, rw_repo)
                except:
                    print >> sys.stderr, "Keeping repo after failure: %s" % repo_dir
                    repo_dir = None
                    raise
            finally:
                os.chdir(prev_cwd)
                rw_repo.git.clear_cache()
                if repo_dir is not None:
                    shutil.rmtree(repo_dir, onerror=_rmtree_onerror)
コード例 #3
0
ファイル: helper.py プロジェクト: JustAnotherChad/GitPython
        def remote_repo_creator(self):
            remote_repo_dir = maketemp("remote_repo_%s" % func.__name__)
            repo_dir = maketemp("remote_clone_non_bare_repo")

            rw_remote_repo = self.rorepo.clone(remote_repo_dir, shared=True, bare=True)
            # recursive alternates info ?
            rw_repo = rw_remote_repo.clone(repo_dir, shared=True, bare=False, n=True)
            rw_repo.head.commit = working_tree_ref
            rw_repo.head.reference.checkout()

            # prepare for git-daemon
            rw_remote_repo.daemon_export = True

            # this thing is just annoying !
            crw = rw_remote_repo.config_writer()
            section = "daemon"
            try:
                crw.add_section(section)
            except Exception:
                pass
            crw.set(section, "receivepack", True)
            # release lock
            del(crw)

            # initialize the remote - first do it as local remote and pull, then
            # we change the url to point to the daemon. The daemon should be started
            # by the user, not by us
            d_remote = Remote.create(rw_repo, "daemon_origin", remote_repo_dir)
            d_remote.fetch()
            remote_repo_url = "git://localhost%s" % remote_repo_dir

            d_remote.config_writer.set('url', remote_repo_url)

            # try to list remotes to diagnoes whether the server is up
            try:
                rw_repo.git.ls_remote(d_remote)
            except GitCommandError, e:
                print str(e)
                if os.name == 'nt':
                    raise AssertionError(
                        'git-daemon needs to run this test, but windows does not have one. Otherwise, run: git-daemon "%s"' % os.path.dirname(_mktemp()))
                else:
                    raise AssertionError(
                        'Please start a git-daemon to run this test, execute: git-daemon "%s"' % os.path.dirname(_mktemp()))