diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-28 18:09:18 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-28 18:09:18 +0100 |
commit | a519942a295cc39af4eebb7ba74b184decae13fb (patch) | |
tree | bd9622deae2a72102c809272b758d31aa1ca9ba8 | |
parent | 4712c619ed6a2ce54b781fe404fedc269b77e5dd (diff) | |
download | gitpython-a519942a295cc39af4eebb7ba74b184decae13fb.tar.gz |
Tried to use shallow repository - this works in case it is remote, but unfortunately, deepening the repository fails if the server is used. This is bad, but a workaround is to create another shared repo which pushes a changes that we fetch into our given repo. This should provide more output to properly test the fetch handling. Harder than I thought
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | test/git/test_remote.py | 19 | ||||
-rw-r--r-- | test/testlib/helper.py | 35 |
3 files changed, 51 insertions, 5 deletions
@@ -43,6 +43,8 @@ Config it will be returned instead of raising. This way the class will be much more usable, and ... I truly hate this config reader as it is so 'old' style. Its not even a new-style class yet showing that it must be ten years old. + - If you are at it, why not start a new project that reimplements the ConfigWriter + properly, honestly. Tune it for usability ... . Diff ---- diff --git a/test/git/test_remote.py b/test/git/test_remote.py index 152ef5ab..99f64756 100644 --- a/test/git/test_remote.py +++ b/test/git/test_remote.py @@ -6,7 +6,8 @@ from test.testlib import * from git import * - +import tempfile +import shutil import os class TestRemote(TestBase): @@ -122,6 +123,20 @@ class TestRemote(TestBase): res = fetch_and_test(remote, tags=True) self.failUnlessRaises(IndexError, get_info, res, remote, str(rtag)) + # provoke to receive actual objects to see what kind of output we have to + # expect. Previously we did not really receive new objects + # This will only work for true remote repositories, not for local ones ! + if not remote.config_reader.get('url').startswith("git://"): + return + + shallow_repo_dir = tempfile.mktemp("shallow_repo") + shallow_repo = remote_repo.clone(shallow_repo_dir, depth=1, shared=False) + try: + res = shallow_repo.remotes.origin.fetch(depth=10) + finally: + shutil.rmtree(shallow_repo_dir) + # END test and cleanup + def _test_push_and_pull(self,remote, rw_repo, remote_repo): # push our changes lhead = rw_repo.head @@ -149,7 +164,7 @@ class TestRemote(TestBase): remote.pull('master') @with_rw_and_rw_remote_repo('0.1.6') - def test_base(self, rw_repo, remote_repo, damon_handle): + def test_base(self, rw_repo, remote_repo): num_remotes = 0 remote_set = set() diff --git a/test/testlib/helper.py b/test/testlib/helper.py index d541a111..081299be 100644 --- a/test/testlib/helper.py +++ b/test/testlib/helper.py @@ -5,7 +5,7 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php import os -from git import Repo +from git import Repo, Remote from unittest import TestCase import tempfile import shutil @@ -115,8 +115,15 @@ def with_rw_repo(working_tree_ref): def with_rw_and_rw_remote_repo(working_tree_ref): """ Same as with_rw_repo, but also provides a writable remote repository from which the - rw_repo has been forked. The remote repository was cloned as bare repository from - the rorepo, wheras the rw repo has a working tree and was cloned from the remote repository. + rw_repo has been forked as well as a handle for a git-daemon that may be started to + run the remote_repo. + The remote repository was cloned as bare repository from the rorepo, wheras + the rw repo has a working tree and was cloned from the remote repository. + + remote_repo has two remotes: origin and daemon_origin. One uses a local url, + the other uses a server url. The daemon setup must be done on system level + and should be an inetd service that serves tempdir.gettempdir() and all + directories in it. The following scetch demonstrates this:: rorepo ---<bare clone>---> rw_remote_repo ---<clone>---> rw_repo @@ -135,6 +142,28 @@ def with_rw_and_rw_remote_repo(working_tree_ref): 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.git.checkout("-b", "master", working_tree_ref) + + # 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() + d_remote.config_writer.set('url', "git://localhost%s" % remote_repo_dir) + try: return func(self, rw_repo, rw_remote_repo) finally: |