From 83a30dfd495f0b8e90b7b5725c946c659ecbd93d Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 8 Jan 2015 20:57:45 +0000 Subject: bitbake: fetch/git: Improve ls-remote handling for latest_revision Currently the code ignores lightweight tags which has caused some user complaints. We can't put the right search list in place easily since the results don't come back in a good order, head happens to sort before tags. In the end I refactored the function so we get the complete list of remotes and then we can filter it ourselves in the order we chose, including checking for light weight tags, preferring the proper ones. Hopefully this resolves the issues people have been seeing. [YOCTO #6881] (Bitbake rev: 07ad307065bb15a48f0015b9e4a643201abdc283) Signed-off-by: Richard Purdie --- bitbake/lib/bb/fetch2/git.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'bitbake/lib/bb/fetch2/git.py') diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index f771fd02b6..44fc27193e 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py @@ -340,12 +340,19 @@ class Git(FetchMethod): """ Compute the HEAD revision for the url """ + output = self._lsremote(ud, d, "") + # Tags of the form ^{} may not work, need to fallback to other form if ud.unresolvedrev[name][:5] == "refs/": - search = "%s %s^{}" % (ud.unresolvedrev[name], ud.unresolvedrev[name]) + head = ud.unresolvedrev[name] + tag = ud.unresolvedrev[name] else: - search = "refs/heads/%s refs/tags/%s^{}" % (ud.unresolvedrev[name], ud.unresolvedrev[name]) - output = self._lsremote(ud, d, search) - return output.split()[0] + head = "refs/heads/%s" % ud.unresolvedrev[name] + tag = "refs/tags/%s" % ud.unresolvedrev[name] + for s in [head, tag + "^{}", tag]: + for l in output.split('\n'): + if s in l: + return l.split()[0] + raise bb.fetch2.FetchError("Unable to resolve '%s' in upstream git repository in git ls-remote output" % ud.unresolvedrev[name]) def latest_versionstring(self, ud, d): """ -- cgit v1.2.3-54-g00ecf