Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4a771ad

Browse files
committed
fix(remote): assert fetch respec is set
It turns out we can't deal do fetches if no refspec is set as gitwill change the format of the fetch return values, providing lessinformation than usual.A test was added to show that such a case will fail, and an assertionwill assure we don't attempt to fetch/pull if there is no refspecfor 'fetch'.Closes#296
1 parent982eefb commit4a771ad

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

‎git/remote.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,18 @@ def stdout_handler(line):
604604
raise
605605
returnoutput
606606

607+
def_assert_refspec(self):
608+
"""Turns out we can't deal with remotes if the refspec is missing"""
609+
config=self.config_reader
610+
try:
611+
ifconfig.get_value('fetch',default=type)istype:
612+
msg="Remote '%s' has no refspec set.\n"
613+
msg+="You can set it as follows:"
614+
msg+=" 'git config --add\"remote.%s.fetch +refs/heads/*:refs/heads/*\"'."%self.name
615+
raiseAssertionError(msg)
616+
finally:
617+
config.release()
618+
607619
deffetch(self,refspec=None,progress=None,**kwargs):
608620
"""Fetch the latest changes for this remote
609621
@@ -631,6 +643,7 @@ def fetch(self, refspec=None, progress=None, **kwargs):
631643
:note:
632644
As fetch does not provide progress information to non-ttys, we cannot make
633645
it available here unfortunately as in the 'push' method."""
646+
self._assert_refspec()
634647
kwargs=add_progress(kwargs,self.repo.git,progress)
635648
ifisinstance(refspec,list):
636649
args=refspec
@@ -651,6 +664,7 @@ def pull(self, refspec=None, progress=None, **kwargs):
651664
:param progress: see 'push' method
652665
:param kwargs: Additional arguments to be passed to git-pull
653666
:return: Please see 'fetch' method """
667+
self._assert_refspec()
654668
kwargs=add_progress(kwargs,self.repo.git,progress)
655669
proc=self.repo.git.pull(self,refspec,with_extended_output=True,as_process=True,v=True,**kwargs)
656670
res=self._get_fetch_info_from_stderr(proc,progressorRemoteProgress())

‎git/test/test_remote.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,11 @@ def test_fetch_info(self):
494494
fetch_info_line_fmt="c437ee5deb8d00cf02f03720693e4c802e99f390not-for-merge%s '0.3' of "
495495
fetch_info_line_fmt+="git://github.com/gitpython-developers/GitPython"
496496
remote_info_line_fmt="* [new branch] nomatter -> %s"
497+
498+
self.failUnlessRaises(ValueError,FetchInfo._from_line,self.rorepo,
499+
remote_info_line_fmt%"refs/something/branch",
500+
"269c498e56feb93e408ed4558c8138d750de8893\t\t/Users/ben/test/foo\n")
501+
497502
fi=FetchInfo._from_line(self.rorepo,
498503
remote_info_line_fmt%"local/master",
499504
fetch_info_line_fmt%'remote-tracking branch')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp