summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--lib/git/repo.py2
-rw-r--r--test/git/test_remote.py64
3 files changed, 54 insertions, 14 deletions
diff --git a/TODO b/TODO
index 08c77a74..3a31976c 100644
--- a/TODO
+++ b/TODO
@@ -104,6 +104,8 @@ Refs
Remote
------
+* iter_items should parse the configuration file manually - currently a command
+ is issued which is much slower than it has to be ( compared to manual parsing )
* 'push' method needs a test, a true test repository is required though, a fork
of a fork would do :)!
* Fetch should return heads that where updated, pull as well.
diff --git a/lib/git/repo.py b/lib/git/repo.py
index 2383eb2a..d81106c0 100644
--- a/lib/git/repo.py
+++ b/lib/git/repo.py
@@ -625,7 +625,7 @@ class Repo(object):
Create a clone from this repository.
``path``
- is the full path of the new repo (traditionally ends with /<name>.git)
+ is the full path of the new repo (traditionally ends with ./<name>.git).
``kwargs``
keyword arguments to be given to the git-clone command
diff --git a/test/git/test_remote.py b/test/git/test_remote.py
index 99f64756..e4ad5638 100644
--- a/test/git/test_remote.py
+++ b/test/git/test_remote.py
@@ -9,6 +9,10 @@ from git import *
import tempfile
import shutil
import os
+import random
+
+# assure we have repeatable results
+random.seed(0)
class TestRemote(TestBase):
@@ -37,6 +41,15 @@ class TestRemote(TestBase):
self.failUnlessRaises(ValueError, FetchInfo._from_line, repo, "nonsense", '')
self.failUnlessRaises(ValueError, FetchInfo._from_line, repo, "? [up to date] 0.1.7RC -> origin/0.1.7RC", '')
+ def _commit_random_file(self, repo):
+ #Create a file with a random name and random data and commit it to repo.
+ # Return the commited absolute file path
+ index = repo.index
+ new_file = self._make_file(os.path.basename(tempfile.mktemp()),str(random.random()), repo)
+ index.add([new_file])
+ index.commit("Committing %s" % new_file)
+ return new_file
+
def _test_fetch(self,remote, rw_repo, remote_repo):
# specialized fetch testing to de-clutter the main test
self._test_fetch_info(rw_repo)
@@ -124,20 +137,39 @@ class TestRemote(TestBase):
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)
+ # expect. For that we need a remote transport protocol
+ # Create a new UN-shared repo and fetch into it after we pushed a change
+ # to the shared repo
+ other_repo_dir = tempfile.mktemp("other_repo")
+ # must clone with a local path for the repo implementation not to freak out
+ # as it wants local paths only ( which I can understand )
+ other_repo = remote_repo.clone(other_repo_dir, shared=False)
+ remote_repo_url = "git://localhost%s"%remote_repo.path
+
+ # put origin to git-url
+ other_origin = other_repo.remotes.origin
+ other_origin.config_writer.set("url", remote_repo_url)
+ # it automatically creates alternates as remote_repo is shared as well.
+ # It will use the transport though and ignore alternates when fetching
+ # assert not other_repo.alternates # this would fail
+
+ # assure we are in the right state
+ rw_repo.head.reset(remote.refs.master, working_tree=True)
try:
- res = shallow_repo.remotes.origin.fetch(depth=10)
+ self._commit_random_file(rw_repo)
+ remote.push(rw_repo.head.reference)
+
+ # here I would expect to see remote-information about packing
+ # objects and so on. Unfortunately, this does not happen
+ # if we are redirecting the output - git explicitly checks for this
+ # and only provides progress information to ttys
+ res = fetch_and_test(other_origin)
finally:
- shutil.rmtree(shallow_repo_dir)
+ shutil.rmtree(other_repo_dir)
# END test and cleanup
def _test_push_and_pull(self,remote, rw_repo, remote_repo):
+ return
# push our changes
lhead = rw_repo.head
lindex = rw_repo.index
@@ -146,11 +178,10 @@ class TestRemote(TestBase):
lhead.reset(remote.refs.master, working_tree=True)
# push without spec should fail ( without further configuration )
+ # well, works
# self.failUnlessRaises(GitCommandError, remote.push)
- new_file = self._make_file("new_file", "hello world", rw_repo)
- lindex.add([new_file])
- lindex.commit("test commit")
+ self._commit_random_file(rw_repo)
remote.push(lhead.reference)
self.fail("test --all")
@@ -167,6 +198,7 @@ class TestRemote(TestBase):
def test_base(self, rw_repo, remote_repo):
num_remotes = 0
remote_set = set()
+ ran_fetch_test = False
for remote in rw_repo.remotes:
num_remotes += 1
@@ -215,7 +247,12 @@ class TestRemote(TestBase):
# END for each rename ( back to prev_name )
# FETCH TESTING
- self._test_fetch(remote, rw_repo, remote_repo)
+ # Only for remotes - local cases are the same or less complicated
+ # as additional progress information will never be emitted
+ if remote.name == "daemon_origin":
+ self._test_fetch(remote, rw_repo, remote_repo)
+ ran_fetch_test = True
+ # END fetch test
# PULL TESTING
self._test_push_and_pull(remote, rw_repo, remote_repo)
@@ -223,6 +260,7 @@ class TestRemote(TestBase):
remote.update()
# END for each remote
+ assert ran_fetch_test
assert num_remotes
assert num_remotes == len(remote_set)