Skip to content

Support multiple refspecs in fetch. #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,10 @@ def fetch(self, refspec=None, progress=None, **kwargs):
See also git-push(1).

Taken from the git manual

Fetch supports multiple refspecs (as the
underlying git-fetch does) - supplying a list rather than a string
for 'refspec' will make use of this facility.
:param progress: See 'push' method
:param kwargs: Additional arguments to be passed to git-fetch
:return:
Expand All @@ -593,7 +597,11 @@ def fetch(self, refspec=None, progress=None, **kwargs):
As fetch does not provide progress information to non-ttys, we cannot make
it available here unfortunately as in the 'push' method."""
kwargs = add_progress(kwargs, self.repo.git, progress)
proc = self.repo.git.fetch(self, refspec, with_extended_output=True, as_process=True, v=True, **kwargs)
if isinstance(refspec, list):
args = refspec
else:
args = [refspec]
proc = self.repo.git.fetch(self, *args, with_extended_output=True, as_process=True, v=True, **kwargs)
return self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())

def pull(self, refspec=None, progress=None, **kwargs):
Expand Down
4 changes: 4 additions & 0 deletions git/test/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ def get_info(res, remote, name):
# ... with respec and no target
res = fetch_and_test(remote, refspec='master')
assert len(res) == 1

# ... multiple refspecs
res = fetch_and_test(remote, refspec=['master', 'fred'])
assert len(res) == 1

# add new tag reference
rtag = TagReference.create(remote_repo, "1.0-RV_hello.there")
Expand Down