| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 685d6e6 commit 8b51214
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104,6 +104,8 @@ Refs | |||
| 104 | 104 | ||
| 105 | 105 | Remote | |
| 106 | 106 | ------ | |
| 107 | + * iter_items should parse the configuration file manually - currently a command | ||
| 108 | + is issued which is much slower than it has to be ( compared to manual parsing ) | ||
| 107 | 109 | * 'push' method needs a test, a true test repository is required though, a fork | |
| 108 | 110 | of a fork would do :)! | |
| 109 | 111 | * Fetch should return heads that where updated, pull as well. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -625,7 +625,7 @@ def clone(self, path, **kwargs): | |||
| 625 | 625 | Create a clone from this repository. | |
| 626 | 626 | ||
| 627 | 627 | ``path`` | |
| 628 | - is the full path of the new repo (traditionally ends with /<name>.git) | ||
| 628 | + is the full path of the new repo (traditionally ends with ./<name>.git). | ||
| 629 | 629 | ||
| 630 | 630 | ``kwargs`` | |
| 631 | 631 | keyword arguments to be given to the git-clone command | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,10 @@ | |||
| 9 | 9 | import tempfile | |
| 10 | 10 | import shutil | |
| 11 | 11 | import os | |
| 12 | + import random | ||
| 13 | + | ||
| 14 | + # assure we have repeatable results | ||
| 15 | + random.seed(0) | ||
| 12 | 16 | ||
| 13 | 17 | class TestRemote(TestBase): | |
| 14 | 18 | ||
@@ -37,6 +41,15 @@ def _test_fetch_info(self, repo): | |||
| 37 | 41 | self.failUnlessRaises(ValueError, FetchInfo._from_line, repo, "nonsense", '') | |
| 38 | 42 | self.failUnlessRaises(ValueError, FetchInfo._from_line, repo, "? [up to date] 0.1.7RC -> origin/0.1.7RC", '') | |
| 39 | 43 | ||
| 44 | + def _commit_random_file(self, repo): | ||
| 45 | + #Create a file with a random name and random data and commit it to repo. | ||
| 46 | + # Return the commited absolute file path | ||
| 47 | + index = repo.index | ||
| 48 | + new_file = self._make_file(os.path.basename(tempfile.mktemp()),str(random.random()), repo) | ||
| 49 | + index.add([new_file]) | ||
| 50 | + index.commit("Committing %s" % new_file) | ||
| 51 | + return new_file | ||
| 52 | + | ||
| 40 | 53 | def _test_fetch(self,remote, rw_repo, remote_repo): | |
| 41 | 54 | # specialized fetch testing to de-clutter the main test | |
| 42 | 55 | self._test_fetch_info(rw_repo) | |
@@ -124,20 +137,39 @@ def get_info(res, remote, name): | |||
| 124 | 137 | self.failUnlessRaises(IndexError, get_info, res, remote, str(rtag)) | |
| 125 | 138 | ||
| 126 | 139 | # 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) | ||
| 140 | + # expect. For that we need a remote transport protocol | ||
| 141 | + # Create a new UN-shared repo and fetch into it after we pushed a change | ||
| 142 | + # to the shared repo | ||
| 143 | + other_repo_dir = tempfile.mktemp("other_repo") | ||
| 144 | + # must clone with a local path for the repo implementation not to freak out | ||
| 145 | + # as it wants local paths only ( which I can understand ) | ||
| 146 | + other_repo = remote_repo.clone(other_repo_dir, shared=False) | ||
| 147 | + remote_repo_url = "git://localhost%s"%remote_repo.path | ||
| 148 | + | ||
| 149 | + # put origin to git-url | ||
| 150 | + other_origin = other_repo.remotes.origin | ||
| 151 | + other_origin.config_writer.set("url", remote_repo_url) | ||
| 152 | + # it automatically creates alternates as remote_repo is shared as well. | ||
| 153 | + # It will use the transport though and ignore alternates when fetching | ||
| 154 | + # assert not other_repo.alternates # this would fail | ||
| 155 | + | ||
| 156 | + # assure we are in the right state | ||
| 157 | + rw_repo.head.reset(remote.refs.master, working_tree=True) | ||
| 134 | 158 | try: | |
| 135 | - res = shallow_repo.remotes.origin.fetch(depth=10) | ||
| 159 | + self._commit_random_file(rw_repo) | ||
| 160 | + remote.push(rw_repo.head.reference) | ||
| 161 | + | ||
| 162 | + # here I would expect to see remote-information about packing | ||
| 163 | + # objects and so on. Unfortunately, this does not happen | ||
| 164 | + # if we are redirecting the output - git explicitly checks for this | ||
| 165 | + # and only provides progress information to ttys | ||
| 166 | + res = fetch_and_test(other_origin) | ||
| 136 | 167 | finally: | |
| 137 | - shutil.rmtree(shallow_repo_dir) | ||
| 168 | + shutil.rmtree(other_repo_dir) | ||
| 138 | 169 | # END test and cleanup | |
| 139 | 170 | ||
| 140 | 171 | def _test_push_and_pull(self,remote, rw_repo, remote_repo): | |
| 172 | + return | ||
| 141 | 173 | # push our changes | |
| 142 | 174 | lhead = rw_repo.head | |
| 143 | 175 | lindex = rw_repo.index | |
@@ -146,11 +178,10 @@ def _test_push_and_pull(self,remote, rw_repo, remote_repo): | |||
| 146 | 178 | lhead.reset(remote.refs.master, working_tree=True) | |
| 147 | 179 | ||
| 148 | 180 | # push without spec should fail ( without further configuration ) | |
| 181 | + # well, works | ||
| 149 | 182 | # self.failUnlessRaises(GitCommandError, remote.push) | |
| 150 | 183 | ||
| 151 | - new_file = self._make_file("new_file", "hello world", rw_repo) | ||
| 152 | - lindex.add([new_file]) | ||
| 153 | - lindex.commit("test commit") | ||
| 184 | + self._commit_random_file(rw_repo) | ||
| 154 | 185 | remote.push(lhead.reference) | |
| 155 | 186 | ||
| 156 | 187 | self.fail("test --all") | |
@@ -167,6 +198,7 @@ def _test_push_and_pull(self,remote, rw_repo, remote_repo): | |||
| 167 | 198 | def test_base(self, rw_repo, remote_repo): | |
| 168 | 199 | num_remotes = 0 | |
| 169 | 200 | remote_set = set() | |
| 201 | + ran_fetch_test = False | ||
| 170 | 202 | ||
| 171 | 203 | for remote in rw_repo.remotes: | |
| 172 | 204 | num_remotes += 1 | |
@@ -215,14 +247,20 @@ def test_base(self, rw_repo, remote_repo): | |||
| 215 | 247 | # END for each rename ( back to prev_name ) | |
| 216 | 248 | ||
| 217 | 249 | # FETCH TESTING | |
| 218 | - self._test_fetch(remote, rw_repo, remote_repo) | ||
| 250 | + # Only for remotes - local cases are the same or less complicated | ||
| 251 | + # as additional progress information will never be emitted | ||
| 252 | + if remote.name == "daemon_origin": | ||
| 253 | + self._test_fetch(remote, rw_repo, remote_repo) | ||
| 254 | + ran_fetch_test = True | ||
| 255 | + # END fetch test | ||
| 219 | 256 | ||
| 220 | 257 | # PULL TESTING | |
| 221 | 258 | self._test_push_and_pull(remote, rw_repo, remote_repo) | |
| 222 | 259 | ||
| 223 | 260 | remote.update() | |
| 224 | 261 | # END for each remote | |
| 225 | 262 | ||
| 263 | + assert ran_fetch_test | ||
| 226 | 264 | assert num_remotes | |
| 227 | 265 | assert num_remotes == len(remote_set) | |
| 228 | 266 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments