| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4712c61 commit a519942
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,6 +43,8 @@ Config | |||
| 43 | 43 | it will be returned instead of raising. This way the class will be much more usable, | |
| 44 | 44 | and ... I truly hate this config reader as it is so 'old' style. Its not even a new-style | |
| 45 | 45 | class yet showing that it must be ten years old. | |
| 46 | + - If you are at it, why not start a new project that reimplements the ConfigWriter | ||
| 47 | + properly, honestly. Tune it for usability ... . | ||
| 46 | 48 | ||
| 47 | 49 | Diff | |
| 48 | 50 | ---- | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,8 @@ | |||
| 6 | 6 | ||
| 7 | 7 | from test.testlib import * | |
| 8 | 8 | from git import * | |
| 9 | - | ||
| 9 | + import tempfile | ||
| 10 | + import shutil | ||
| 10 | 11 | import os | |
| 11 | 12 | ||
| 12 | 13 | class TestRemote(TestBase): | |
@@ -122,6 +123,20 @@ def get_info(res, remote, name): | |||
| 122 | 123 | res = fetch_and_test(remote, tags=True) | |
| 123 | 124 | self.failUnlessRaises(IndexError, get_info, res, remote, str(rtag)) | |
| 124 | 125 | ||
| 126 | + # provoke to receive actual objects to see what kind of output we have to | ||
| 127 | + # expect. Previously we did not really receive new objects | ||
| 128 | + # This will only work for true remote repositories, not for local ones ! | ||
| 129 | + if not remote.config_reader.get('url').startswith("git://"): | ||
| 130 | + return | ||
| 131 | + | ||
| 132 | + shallow_repo_dir = tempfile.mktemp("shallow_repo") | ||
| 133 | + shallow_repo = remote_repo.clone(shallow_repo_dir, depth=1, shared=False) | ||
| 134 | + try: | ||
| 135 | + res = shallow_repo.remotes.origin.fetch(depth=10) | ||
| 136 | + finally: | ||
| 137 | + shutil.rmtree(shallow_repo_dir) | ||
| 138 | + # END test and cleanup | ||
| 139 | + | ||
| 125 | 140 | def _test_push_and_pull(self,remote, rw_repo, remote_repo): | |
| 126 | 141 | # push our changes | |
| 127 | 142 | lhead = rw_repo.head | |
@@ -149,7 +164,7 @@ def _test_push_and_pull(self,remote, rw_repo, remote_repo): | |||
| 149 | 164 | remote.pull('master') | |
| 150 | 165 | ||
| 151 | 166 | @with_rw_and_rw_remote_repo('0.1.6') | |
| 152 | - def test_base(self, rw_repo, remote_repo, damon_handle): | ||
| 167 | + def test_base(self, rw_repo, remote_repo): | ||
| 153 | 168 | num_remotes = 0 | |
| 154 | 169 | remote_set = set() | |
| 155 | 170 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ | |||
| 5 | 5 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 6 | 6 | ||
| 7 | 7 | import os | |
| 8 | - from git import Repo | ||
| 8 | + from git import Repo, Remote | ||
| 9 | 9 | from unittest import TestCase | |
| 10 | 10 | import tempfile | |
| 11 | 11 | import shutil | |
@@ -115,8 +115,15 @@ def repo_creator(self): | |||
| 115 | 115 | def with_rw_and_rw_remote_repo(working_tree_ref): | |
| 116 | 116 | """ | |
| 117 | 117 | Same as with_rw_repo, but also provides a writable remote repository from which the | |
| 118 | - rw_repo has been forked. The remote repository was cloned as bare repository from | ||
| 119 | - the rorepo, wheras the rw repo has a working tree and was cloned from the remote repository. | ||
| 118 | + rw_repo has been forked as well as a handle for a git-daemon that may be started to | ||
| 119 | + run the remote_repo. | ||
| 120 | + The remote repository was cloned as bare repository from the rorepo, wheras | ||
| 121 | + the rw repo has a working tree and was cloned from the remote repository. | ||
| 122 | + | ||
| 123 | + remote_repo has two remotes: origin and daemon_origin. One uses a local url, | ||
| 124 | + the other uses a server url. The daemon setup must be done on system level | ||
| 125 | + and should be an inetd service that serves tempdir.gettempdir() and all | ||
| 126 | + directories in it. | ||
| 120 | 127 | ||
| 121 | 128 | The following scetch demonstrates this:: | |
| 122 | 129 | rorepo ---<bare clone>---> rw_remote_repo ---<clone>---> rw_repo | |
@@ -135,6 +142,28 @@ def remote_repo_creator(self): | |||
| 135 | 142 | rw_remote_repo = self.rorepo.clone(remote_repo_dir, shared=True, bare=True) | |
| 136 | 143 | rw_repo = rw_remote_repo.clone(repo_dir, shared=True, bare=False, n=True) # recursive alternates info ? | |
| 137 | 144 | rw_repo.git.checkout("-b", "master", working_tree_ref) | |
| 145 | + | ||
| 146 | + # prepare for git-daemon | ||
| 147 | + rw_remote_repo.daemon_export = True | ||
| 148 | + | ||
| 149 | + # this thing is just annoying ! | ||
| 150 | + crw = rw_remote_repo.config_writer() | ||
| 151 | + section = "daemon" | ||
| 152 | + try: | ||
| 153 | + crw.add_section(section) | ||
| 154 | + except Exception: | ||
| 155 | + pass | ||
| 156 | + crw.set(section, "receivepack", True) | ||
| 157 | + # release lock | ||
| 158 | + del(crw) | ||
| 159 | + | ||
| 160 | + # initialize the remote - first do it as local remote and pull, then | ||
| 161 | + # we change the url to point to the daemon. The daemon should be started | ||
| 162 | + # by the user, not by us | ||
| 163 | + d_remote = Remote.create(rw_repo, "daemon_origin", remote_repo_dir) | ||
| 164 | + d_remote.fetch() | ||
| 165 | + d_remote.config_writer.set('url', "git://localhost%s" % remote_repo_dir) | ||
| 166 | + | ||
| 138 | 167 | try: | |
| 139 | 168 | return func(self, rw_repo, rw_remote_repo) | |
| 140 | 169 | finally: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments