diff options
Diffstat (limited to 'bitbake/lib/bb/fetch2/git.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index 66a77a8376..f771fd02b6 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
@@ -67,6 +67,7 @@ Supported SRC_URI options are: | |||
67 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 67 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
68 | 68 | ||
69 | import os | 69 | import os |
70 | import re | ||
70 | import bb | 71 | import bb |
71 | from bb import data | 72 | from bb import data |
72 | from bb.fetch2 import FetchMethod | 73 | from bb.fetch2 import FetchMethod |
@@ -346,6 +347,43 @@ class Git(FetchMethod): | |||
346 | output = self._lsremote(ud, d, search) | 347 | output = self._lsremote(ud, d, search) |
347 | return output.split()[0] | 348 | return output.split()[0] |
348 | 349 | ||
350 | def latest_versionstring(self, ud, d): | ||
351 | """ | ||
352 | Compute the latest release name like "x.y.x" in "x.y.x+gitHASH" | ||
353 | by searching through the tags output of ls-remote, comparing | ||
354 | versions and returning the highest match. | ||
355 | """ | ||
356 | verstring = "" | ||
357 | tagregex = re.compile(d.getVar('GITTAGREGEX', True) or "(?P<pver>([0-9][\.|_]?)+)") | ||
358 | try: | ||
359 | output = self._lsremote(ud, d, "refs/tags/*^{}") | ||
360 | except bb.fetch2.FetchError or bb.fetch2.NetworkAccess: | ||
361 | return "" | ||
362 | |||
363 | for line in output.split("\n"): | ||
364 | if not line: | ||
365 | break | ||
366 | |||
367 | line = line.split("/")[-1] | ||
368 | # Ignore non-released branches | ||
369 | m = re.search("(alpha|beta|rc|final)+", line) | ||
370 | if m: | ||
371 | continue | ||
372 | |||
373 | # search for version in the line | ||
374 | tag = tagregex.search(line) | ||
375 | if tag == None: | ||
376 | continue | ||
377 | |||
378 | tag = tag.group('pver') | ||
379 | tag = tag.replace("_", ".") | ||
380 | |||
381 | if verstring and bb.utils.vercmp(("0", tag, ""), ("0", verstring, "")) < 0: | ||
382 | continue | ||
383 | verstring = tag | ||
384 | |||
385 | return verstring | ||
386 | |||
349 | def _build_revision(self, ud, d, name): | 387 | def _build_revision(self, ud, d, name): |
350 | return ud.revisions[name] | 388 | return ud.revisions[name] |
351 | 389 | ||