summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/git.py
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2014-11-05 12:10:28 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-11-12 15:25:17 +0000
commit7587877e5d683a30c2bd5e1ac1c4e327fac1ee1c (patch)
tree46be36149f9f63ce1a0a47268c8bcdaba318f65d /bitbake/lib/bb/fetch2/git.py
parent95c7b399518d102cd748c19017c564a53375c58c (diff)
downloadpoky-7587877e5d683a30c2bd5e1ac1c4e327fac1ee1c.tar.gz
bitbake: fetch/git: Add latest_versionstring method
Being able to generate a version string representing the most recent git commit given git is useful, not least for the package reporting system. This adds in a latest_versionstring method to the git fetcher which allows users to query the latest version using ls-remote and filtering the responses. The patch also adds unittests for this function so that if improvements are made, the original test urls can be used to evaulate the those changes. This is based on code from Irina Patru <irina.patru@intel.com>. (Bitbake rev: f71c8c0354e87fed80bc845db6728e6e18ce9c4d) Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/git.py')
-rw-r--r--bitbake/lib/bb/fetch2/git.py38
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
69import os 69import os
70import re
70import bb 71import bb
71from bb import data 72from bb import data
72from bb.fetch2 import FetchMethod 73from 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