diff options
Diffstat (limited to 'bitbake')
| -rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 10 | ||||
| -rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 44 |
2 files changed, 51 insertions, 3 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index ecaf0a49af..52fffe21d7 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
| @@ -323,6 +323,8 @@ class Git(FetchMethod): | |||
| 323 | return True | 323 | return True |
| 324 | if not self._contains_ref(ud, d, ud.name, ud.clonedir): | 324 | if not self._contains_ref(ud, d, ud.name, ud.clonedir): |
| 325 | return True | 325 | return True |
| 326 | if 'tag' in ud.parm and not self._contains_ref(ud, d, ud.name, ud.clonedir, tag=True): | ||
| 327 | return True | ||
| 326 | return False | 328 | return False |
| 327 | 329 | ||
| 328 | def lfs_need_update(self, ud, d): | 330 | def lfs_need_update(self, ud, d): |
| @@ -775,14 +777,16 @@ class Git(FetchMethod): | |||
| 775 | def supports_srcrev(self): | 777 | def supports_srcrev(self): |
| 776 | return True | 778 | return True |
| 777 | 779 | ||
| 778 | def _contains_ref(self, ud, d, name, wd): | 780 | def _contains_ref(self, ud, d, name, wd, tag=False): |
| 779 | cmd = "" | 781 | cmd = "" |
| 782 | git_ref_name = 'refs/tags/%s' % ud.parm['tag'] if tag else ud.revision | ||
| 783 | |||
| 780 | if ud.nobranch: | 784 | if ud.nobranch: |
| 781 | cmd = "%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % ( | 785 | cmd = "%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % ( |
| 782 | ud.basecmd, ud.revision) | 786 | ud.basecmd, git_ref_name) |
| 783 | else: | 787 | else: |
| 784 | cmd = "%s branch --contains %s --list %s 2> /dev/null | wc -l" % ( | 788 | cmd = "%s branch --contains %s --list %s 2> /dev/null | wc -l" % ( |
| 785 | ud.basecmd, ud.revision, ud.branch) | 789 | ud.basecmd, git_ref_name, ud.branch) |
| 786 | try: | 790 | try: |
| 787 | output = runfetchcmd(cmd, d, quiet=True, workdir=wd) | 791 | output = runfetchcmd(cmd, d, quiet=True, workdir=wd) |
| 788 | except bb.fetch2.FetchError: | 792 | except bb.fetch2.FetchError: |
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index cde1bf3390..d216eac2ab 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
| @@ -2647,6 +2647,50 @@ class GitURLWithSpacesTest(FetcherTest): | |||
| 2647 | self.assertEqual(ud.fullmirror, os.path.join(self.dldir, "git2_" + ref['gitsrcname'] + '.tar.gz')) | 2647 | self.assertEqual(ud.fullmirror, os.path.join(self.dldir, "git2_" + ref['gitsrcname'] + '.tar.gz')) |
| 2648 | self.assertEqual(ud.method._get_repo_url(ud), ref['repo_url']) | 2648 | self.assertEqual(ud.method._get_repo_url(ud), ref['repo_url']) |
| 2649 | 2649 | ||
| 2650 | |||
| 2651 | class FetchLocallyMissingTagFromRemote(FetcherTest): | ||
| 2652 | def setUp(self): | ||
| 2653 | FetcherTest.setUp(self) | ||
| 2654 | self.gitdir = os.path.join(self.tempdir, 'git') | ||
| 2655 | self.srcdir = os.path.join(self.tempdir, 'gitsource') | ||
| 2656 | |||
| 2657 | bb.utils.mkdirhier(self.srcdir) | ||
| 2658 | self.git_init(cwd=self.srcdir) | ||
| 2659 | self.d.setVar('WORKDIR', self.tempdir) | ||
| 2660 | self.d.setVar('S', self.gitdir) | ||
| 2661 | |||
| 2662 | uri = 'git://%s;protocol=file;subdir=${S};branch=master' % self.srcdir | ||
| 2663 | self.d.setVar('SRC_URI', uri) | ||
| 2664 | |||
| 2665 | open(os.path.join(self.srcdir, 'dummyfile'), 'w').close() | ||
| 2666 | self.git(['add', 'dummyfile'], self.srcdir) | ||
| 2667 | self.git(['commit', '-m', 'dummymsg', 'dummyfile'], self.srcdir) | ||
| 2668 | |||
| 2669 | def _fetch_and_unpack(self, uri_to_fetch): | ||
| 2670 | fetcher = bb.fetch2.Fetch([uri_to_fetch], self.d) | ||
| 2671 | fetcher.download() | ||
| 2672 | fetcher.unpack(self.d.getVar('WORKDIR')) | ||
| 2673 | |||
| 2674 | def test_tag_present_in_remote_but_not_local(self): | ||
| 2675 | # fetch a repo that has no tag in it | ||
| 2676 | # then add a tag to this repo, and fetch it again, without | ||
| 2677 | # changing SRC_REV, but by adding ';tag=tag1` to SRC_URI | ||
| 2678 | # the new tag should be fetched and unpacked | ||
| 2679 | srcrev = self.git('rev-parse HEAD', cwd=self.srcdir).strip() | ||
| 2680 | self.d.setVar('SRCREV', srcrev) | ||
| 2681 | src_uri = self.d.getVar('SRC_URI') | ||
| 2682 | self._fetch_and_unpack(src_uri) | ||
| 2683 | |||
| 2684 | self.git('tag -m -a tag1', cwd=self.srcdir) | ||
| 2685 | |||
| 2686 | src_uri = '%s;tag=tag1' % self.d.getVar('SRC_URI').split()[0] | ||
| 2687 | self.d.setVar('SRC_URI', src_uri) | ||
| 2688 | self._fetch_and_unpack(src_uri) | ||
| 2689 | |||
| 2690 | output = self.git('log --pretty=oneline -n 1 refs/tags/tag1', cwd=self.gitdir) | ||
| 2691 | assert "fatal: ambiguous argument" not in output | ||
| 2692 | |||
| 2693 | |||
| 2650 | class CrateTest(FetcherTest): | 2694 | class CrateTest(FetcherTest): |
| 2651 | @skipIfNoNetwork() | 2695 | @skipIfNoNetwork() |
| 2652 | def test_crate_url(self): | 2696 | def test_crate_url(self): |
