From 6edcc2fa065194fd29fdeb340d15d9cc4b412a0e Mon Sep 17 00:00:00 2001 From: Holger Freyther Date: Fri, 16 May 2008 12:25:27 +0200 Subject: [PATCH] [git] Optionally use git-rev-list to get a sortable revision With setting BB_GIT_CLONE_FOR_SRCREV="1" you can get a sensible and global (per repository with only fast forwards) revision. The downsides are you will have to have a repository at parse time which means you will git-clone certain trees you don't even use. This is also the reason why this is optional. This also means you might need to download your git checkouts to get this feature working. --- lib/bb/fetch/git.py | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/lib/bb/fetch/git.py b/lib/bb/fetch/git.py index 3de3529..b256fd0 100644 --- a/lib/bb/fetch/git.py +++ b/lib/bb/fetch/git.py @@ -145,3 +145,38 @@ class Git(Fetch): def _build_revision(self, url, ud, d): return ud.tag + def _want_sortable_revision(self, url, ud, d): + return bb.data.getVar("BB_GIT_CLONE_FOR_SRCREV", d, True) or False + + def _sortable_revision(self, url, ud, d): + """ + This is only called when _want_sortable_revision called true + + We will have to get the updated revision. + """ + gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.')) + repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) + + + # Runtime warning on wrongly configured sources + if ud.tag == "1": + bb.msg.error(1, bb.msg.domain.Fetcher, "SRCREV is '1'. This indicates a configuration error of %s" % url) + return "0+1" + + cwd = os.getcwd() + + # Check if we have the rev already + if not os.path.exists(repodir): + print "no repo" + self.go(None, ud, d) + + os.chdir(repodir) + if not self._contains_ref(ud.tag, d): + self.go(None, ud, d) + + output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % ud.tag, d, quiet=True) + os.chdir(cwd) + + return "%s+%s" % (output.split()[0], ud.tag) + + -- 1.5.4.3