summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py13
-rw-r--r--bitbake/lib/bb/fetch2/git.py12
-rw-r--r--bitbake/lib/bb/tests/fetch.py6
3 files changed, 17 insertions, 14 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 5aa67accc3..cfbbce5288 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -1248,20 +1248,17 @@ def srcrev_internal_helper(ud, d, name):
1248 if srcrev and srcrev != "INVALID": 1248 if srcrev and srcrev != "INVALID":
1249 break 1249 break
1250 1250
1251 if 'rev' in ud.parm and 'tag' in ud.parm: 1251 if 'rev' in ud.parm:
1252 raise FetchError("Please specify a ;rev= parameter or a ;tag= parameter in the url %s but not both." % (ud.url)) 1252 parmrev = ud.parm['rev']
1253
1254 if 'rev' in ud.parm or 'tag' in ud.parm:
1255 if 'rev' in ud.parm:
1256 parmrev = ud.parm['rev']
1257 else:
1258 parmrev = ud.parm['tag']
1259 if srcrev == "INVALID" or not srcrev: 1253 if srcrev == "INVALID" or not srcrev:
1260 return parmrev 1254 return parmrev
1261 if srcrev != parmrev: 1255 if srcrev != parmrev:
1262 raise FetchError("Conflicting revisions (%s from SRCREV and %s from the url) found, please specify one valid value" % (srcrev, parmrev)) 1256 raise FetchError("Conflicting revisions (%s from SRCREV and %s from the url) found, please specify one valid value" % (srcrev, parmrev))
1263 return parmrev 1257 return parmrev
1264 1258
1259 if 'tag' in ud.parm and (srcrev == "INVALID" or not srcrev):
1260 return ud.parm['tag']
1261
1265 if srcrev == "INVALID" or not srcrev: 1262 if srcrev == "INVALID" or not srcrev:
1266 raise FetchError("Please set a valid SRCREV for url %s (possible key names are %s, or use a ;rev=X URL parameter)" % (str(attempts), ud.url), ud.url) 1263 raise FetchError("Please set a valid SRCREV for url %s (possible key names are %s, or use a ;rev=X URL parameter)" % (str(attempts), ud.url), ud.url)
1267 if srcrev == "AUTOINC": 1264 if srcrev == "AUTOINC":
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index a73fb79ac8..53fdc4c3df 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -279,6 +279,10 @@ class Git(FetchMethod):
279 ud.unresolvedrev[name] = ud.revisions[name] 279 ud.unresolvedrev[name] = ud.revisions[name]
280 ud.revisions[name] = self.latest_revision(ud, d, name) 280 ud.revisions[name] = self.latest_revision(ud, d, name)
281 281
282 if 'tag' in ud.parm:
283 if len(ud.revisions) != 1:
284 raise bb.fetch2.ParameterError("Git fetcher support for multiple tagged revisions not implemented", ud.url)
285
282 gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.').replace(' ','_').replace('(', '_').replace(')', '_')) 286 gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.').replace(' ','_').replace('(', '_').replace(')', '_'))
283 if gitsrcname.startswith('.'): 287 if gitsrcname.startswith('.'):
284 gitsrcname = gitsrcname[1:] 288 gitsrcname = gitsrcname[1:]
@@ -747,6 +751,14 @@ class Git(FetchMethod):
747 if not source_found: 751 if not source_found:
748 raise bb.fetch2.UnpackError("No up to date source found: " + "; ".join(source_error), ud.url) 752 raise bb.fetch2.UnpackError("No up to date source found: " + "; ".join(source_error), ud.url)
749 753
754 # If there is a tag parameter in the url and we also have a fixed srcrev, check the tag
755 # matches the revision
756 if 'tag' in ud.parm and sha1_re.match(ud.revision):
757 output = runfetchcmd("%s rev-list -n 1 %s" % (ud.basecmd, ud.parm['tag']), d, workdir=destdir)
758 output = output.strip()
759 if output != ud.revision:
760 raise bb.fetch2.FetchError("The revision the git tag '%s' resolved to didn't match the SRCREV in use (%s vs %s)" % (ud.parm['tag'], output, ud.revision), ud.url)
761
750 repourl = self._get_repo_url(ud) 762 repourl = self._get_repo_url(ud)
751 runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, shlex.quote(repourl)), d, workdir=destdir) 763 runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, shlex.quote(repourl)), d, workdir=destdir)
752 764
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index cd81660b1b..b4e9255578 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -1087,12 +1087,6 @@ class FetcherNetworkTest(FetcherTest):
1087 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2) 1087 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2)
1088 1088
1089 @skipIfNoNetwork() 1089 @skipIfNoNetwork()
1090 def test_gitfetch_tagandrev(self):
1091 # SRCREV is set but does not match rev= parameter
1092 url1 = url2 = "git://git.openembedded.org/bitbake;rev=270a05b0b4ba0959fe0624d2a4885d7b70426da5;tag=270a05b0b4ba0959fe0624d2a4885d7b70426da5;protocol=https;branch=master"
1093 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2)
1094
1095 @skipIfNoNetwork()
1096 def test_gitfetch_usehead(self): 1090 def test_gitfetch_usehead(self):
1097 # Since self.gitfetcher() sets SRCREV we expect this to override 1091 # Since self.gitfetcher() sets SRCREV we expect this to override
1098 # `usehead=1' and instead fetch the specified SRCREV. See 1092 # `usehead=1' and instead fetch the specified SRCREV. See