| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 982eefb commit 4a771ad
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -604,6 +604,18 @@ def stdout_handler(line): | |||
| 604 | 604 | raise | |
| 605 | 605 | return output | |
| 606 | 606 | ||
| 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 | + if config.get_value('fetch', default=type) is type: | ||
| 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 | + raise AssertionError(msg) | ||
| 616 | + finally: | ||
| 617 | + config.release() | ||
| 618 | + | ||
| 607 | 619 | def fetch(self, refspec=None, progress=None, **kwargs): | |
| 608 | 620 | """Fetch the latest changes for this remote | |
| 609 | 621 | ||
@@ -631,6 +643,7 @@ def fetch(self, refspec=None, progress=None, **kwargs): | |||
| 631 | 643 | :note: | |
| 632 | 644 | As fetch does not provide progress information to non-ttys, we cannot make | |
| 633 | 645 | it available here unfortunately as in the 'push' method.""" | |
| 646 | + self._assert_refspec() | ||
| 634 | 647 | kwargs = add_progress(kwargs, self.repo.git, progress) | |
| 635 | 648 | if isinstance(refspec, list): | |
| 636 | 649 | args = refspec | |
@@ -651,6 +664,7 @@ def pull(self, refspec=None, progress=None, **kwargs): | |||
| 651 | 664 | :param progress: see 'push' method | |
| 652 | 665 | :param kwargs: Additional arguments to be passed to git-pull | |
| 653 | 666 | :return: Please see 'fetch' method """ | |
| 667 | + self._assert_refspec() | ||
| 654 | 668 | kwargs = add_progress(kwargs, self.repo.git, progress) | |
| 655 | 669 | proc = self.repo.git.pull(self, refspec, with_extended_output=True, as_process=True, v=True, **kwargs) | |
| 656 | 670 | res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress()) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -494,6 +494,11 @@ def test_fetch_info(self): | |||
| 494 | 494 | fetch_info_line_fmt = "c437ee5deb8d00cf02f03720693e4c802e99f390 not-for-merge %s '0.3' of " | |
| 495 | 495 | fetch_info_line_fmt += "git://github.com/gitpython-developers/GitPython" | |
| 496 | 496 | 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 | + | ||
| 497 | 502 | fi = FetchInfo._from_line(self.rorepo, | |
| 498 | 503 | remote_info_line_fmt % "local/master", | |
| 499 | 504 | fetch_info_line_fmt % 'remote-tracking branch') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments