[bitbake-devel] fetch2: probe for branches on version check

Submitted by Konrad Weihmann on Jan. 14, 2019, 10:09 a.m. | Patch ID: 157960

Details

Message ID AM6PR05MB4295F10BC56816A25BB85150CC800@AM6PR05MB4295.eurprd05.prod.outlook.com
State New
Headers show

Commit Message

Konrad Weihmann Jan. 14, 2019, 10:09 a.m.
From 26811e557b963c87ffbcb3448401561ab87751d3 Mon Sep 17 00:00:00 2001
From: Konrad Weihmann <kweihmann@phoenixcontact.com>
Date: Mon, 14 Jan 2019 09:53:16 +0100
Subject: [PATCH] fetch2: probe for branches on version check

If a repository isn't using tags but versioned branches,
bb.fetch2.git.latest_version will fail.
To get at least some kind of information probe for git-tags first and
then for git-branches before giving up.
---
 bitbake/lib/bb/fetch2/git.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

--
2.14.2




..................................................................
Phoenix Contact GmbH & Co. KG

Sitz der Gesellschaft / registered office of the company: 32825 Blomberg
USt-Id-Nr.: DE124613250
Pers. haftende Gesellschafterin / personally liable partner: Phoenix Contact Verwaltungs GmbH
Amtsgericht Lemgo HRB 5273 / district court Lemgo HRB 5273
Kom. Ges. Amtsgericht Lemgo HRA 3746 / limited commercial partnership district court Lemgo HRA 3746 
Geschäftsführer / Executive Board: Frank Stührenberg (Vorsitzender / Chief Executive Officer), Roland Bent, Prof. Dr. Gunther Olesch, Axel Wachholz

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 15858a6241..5cc1fce531 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -611,11 +611,19 @@  class Git(FetchMethod):
         versions and returning the highest match.
         """
         pupver = ('', '')
+        output = None

         tagregex = re.compile(d.getVar('UPSTREAM_CHECK_GITTAGREGEX') or "(?P<pver>([0-9][\.|_]?)+)")
-        try:
-            output = self._lsremote(ud, d, "refs/tags/*")
-        except (bb.fetch2.FetchError, bb.fetch2.NetworkAccess) as e:
+        for needle in ["refs/tags/*", "refs/*"]:
+            try:
+                output = self._lsremote(ud, d, needle)
+                break
+            except (bb.fetch2.NetworkAccess) as e:
+                bb.note("Could not list remote: %s" % str(e))
+                return pupver
+            except (bb.fetch2.FetchError) as e:
+                pass
+        if not output:
             bb.note("Could not list remote: %s" % str(e))
             return pupver